package com.hrt.common.web;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class ReactRouteServlet implements Servlet {

    private String targetURL;

    public ReactRouteServlet(String targetURL){
        this.targetURL = targetURL;
    }

    @Override
    public void init(ServletConfig config) throws ServletException {
        // TODO Auto-generated method stub

    }

    @Override
    public ServletConfig getServletConfig() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res)
        throws ServletException, IOException {
        // forward
        HttpServletRequest request = (HttpServletRequest) req;
        RequestDispatcher dispatcher = request.getRequestDispatcher(targetURL);
        dispatcher.forward(request, res);
    }

    @Override
    public String getServletInfo() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void destroy() {
        // TODO Auto-generated method stub

    }

}
